package com.bikes.mileagetracker

import android.support.multidex.MultiDexApplication
import android.util.Log
import com.bikes.mileagetracker.entity.TrackingEntity
import com.bikes.mileagetracker.entity.UserEntity
import com.bikes.mileagetracker.service.LocationService

class MileageTrackerApplication : MultiDexApplication() {



    init {
        CURRENT_APP = this
    }


    companion object {

        @JvmStatic
        private var CURRENT_USER: UserEntity? = null

        @JvmStatic
        private var CURRENT_TRACKING: TrackingEntity? = null

        @JvmStatic
        private lateinit var CURRENT_APP: MileageTrackerApplication

        @JvmStatic
        fun getCurrentApplication(): MileageTrackerApplication {
            return CURRENT_APP
        }

        @JvmStatic
        fun getCurrentAccount(): UserEntity? {
            return CURRENT_USER
        }

        @JvmStatic
        fun getCurrentTracking(): TrackingEntity?{
            return CURRENT_TRACKING
        }

        @JvmStatic
        fun updateCurrentAccount(userAccount: UserEntity) {
            this.CURRENT_USER = userAccount
        }

        @JvmStatic
        fun updateCurrentTracking(trackingEntity: TrackingEntity?){
            this.CURRENT_TRACKING = trackingEntity
        }


        @JvmStatic
        var MAP_CENTER_FOLLOWING = true

        @JvmStatic
        var MAP_MIN_ZOON_LEVEL = 12.0f
        @JvmStatic
        var MAP_MAX_ZOON_LEVEL = 18.0f
        @JvmStatic
        var MAP_DEFAULT_ZOON_LEVEL = 15.0f



    }

    override fun onTerminate() {
        Log.v("console", "application termiate!")
        super.onTerminate()
        LocationService.CURRENT_LOCATION_SERVICE?.stop()
    }
}